/* $Header: setdefault.c,v 2.2 01/10/02 10:32:12 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME: setdefault                                             */
/* ============                                                        */
/*                                                                     */
/* Author: Tom Przybylski                                              */
/*                                                                     */
/* MODULE PURPOSE:  This module is used by Startup and the command     */
/*   system to reset the Active_Wkfile to it's default values.  These  */
/*   are the values that setpoints have after a total memory reset.    */
/*   (eg. first time a new IQ is turned on!)                           */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <error.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <ramps.h>
#include <zone_config.h>
#include <zone_status.h>
#include <status.h>
#include <sig_types.h>
#include <sigpath.h>
#include <oven.h>
#include <detector.h>
#include <exception.h>
#include <flow.h>
#include <timetable.h>
#include <clock_ui.h>
#include <method.h>
#include <run_ui.h>
#include <valve.h>
#include <sampler.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/


/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/



/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/


/***********************************************************************/
/* FUNCTION: SetDefaultSetpoints                                       */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: Set Active_Wkfile and the stored workfiles to their        */
/*          default values.                                            */
/*                                                                     */
/*                                                                     */
/* RETURNED VALUE: void                                                */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

static void SetDefaultWorkfile (void)
{
  /* Set column pressure ramp defaults. */
  SetPresRampDefaults();

  /* Set Detector Defaults */
  SetDetDefaultSetpts((const void *)FRONT);
  SetDetDefaultSetpts((const void *)BACK);

  /* Set Oven and Zone Defaults */
  SetZoneDefaultSetpts();

  /* Set up Signal Path */
  SetSigPathDefaultSetpts();

  SetPneuDefaultSetpts();

  SetValveDefaultSetpts();

  SetAlsDefaults();

  SetUpDefaultRunTimeTable();
  SetUpDefaultClockTable();

  Active_Wkfile.post_time = 0;

}


void SetDefaultSetpoints (void)
{
  int i;

  /* mark the stored workfiles empty */
  for (i = 0; i < MAX_STORED_WKFILE; i++)
  {
        Stored_Wkfile[i].length = 0;
  }

  SetDefaultWorkfile();
}


UI_ERR SetDefaultMethod (void)
{
   if (RunActivePendingOrPost())
   {
      return NOT_VALID_DURING_RUN;
   }
   else
   {
      SetDefaultWorkfile();
      UpdateInstStatus();
      return OK;
   }
}

